'''数据输入-将python中的集合写入RDD'''
from pyspark import SparkConf, SparkContext

conf = SparkConf().setMaster("local[*]").setAppName("test_spark")
sc = SparkContext(conf=conf)

# 通过parallelize方法将Python对象加载到Spark内，称谓RDD对象
rdd1 = sc.parallelize([1,2,3,4,5])
rdd2 = sc.parallelize((1,2,3,4,5))
rdd3 = sc.parallelize("卡卡螺丝钉解放")
rdd4 = sc.parallelize({1,2,3,4,5})
rdd5 = sc.parallelize({"name":"杨*", "sex":"男", "age":23})

# 若要查看RDD对象中的内容，要使用collect() 方法；
print(rdd1.collect())   # [1, 2, 3, 4, 5]
print(rdd2.collect())   # [1, 2, 3, 4, 5]
print(rdd3.collect())   # ['卡', '卡', '螺', '丝', '钉', '解', '放']
print(rdd4.collect())   # [1, 2, 3, 4, 5]
print(rdd5.collect())   # ['name', 'sex', 'age']

sc.stop()

